import sys
import os
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import *

class Demo(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.parent = parent
        layout = QVBoxLayout()
        layout.setAlignment(Qt.AlignmentFlag.AlignTop)

        toolBar=QToolBar()
        toolBar.addWidget(QLabel('Shadow:'))
        cb=QComboBox()
        cb.addItems(QFrame.Shadow.__members__.keys())
        cb.currentTextChanged.connect(self.OnShadowChanged)
        toolBar.addWidget(cb)

        toolBar.addWidget(QLabel('LineWidth:'))
        spin=QSpinBox()
        spin.setRange(1,30)
        spin.valueChanged.connect(self.OnLineWidthChanged)
        toolBar.addWidget(spin)       

        layout.addWidget(toolBar)
        
        group=QGroupBox('HorizontalLine')
        groupLayout=QVBoxLayout()
        self.hLine=QFrame()
        self.hLine.setFrameShape(QFrame.Shape.HLine)
        groupLayout.addWidget(self.hLine)
        group.setLayout(groupLayout)
        layout.addWidget(group)

        group=QGroupBox('VerticalLine')
        group.setMinimumHeight(300)
        groupLayout=QVBoxLayout()        
        self.vLine=QFrame()
        self.vLine.setFrameShape(QFrame.Shape.VLine)
        groupLayout.addWidget(self.vLine)
        group.setLayout(groupLayout)
        layout.addWidget(group)

        self.setLayout(layout)
    def OnShadowChanged(self,text):
        shadow=QFrame.Shadow[text]
        self.hLine.setFrameShadow(shadow)
        self.vLine.setFrameShadow(shadow)
        self.parent.OnShowMessage(f'Set FrameShadow:{shadow}')
    def OnLineWidthChanged(self,value):
        self.hLine.setLineWidth(value)
        self.vLine.setLineWidth(value)
        self.parent.OnShowMessage(f'Set LineWidth:{value}')
    
def runDemo(parent):
    wigdet =  Demo(parent)
    return wigdet